package com.tangyuan.test.controller;

import com.mybatisflex.core.paginate.Page;
import com.tangyuan.test.entity.APoliticsSubjectClassificationEntity;
import com.tangyuan.test.service.APoliticsSubjectClassificationService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 题目分类 控制层。
 * @author TangYuan
 * @since 1.0
 */
@RestController
@RequestMapping("/aPoliticsSubjectClassification")
public class APoliticsSubjectClassificationController {
    
    @Resource
    private APoliticsSubjectClassificationService aPoliticsSubjectClassificationService;
    
    /**
     * 添加 题目分类
     * @param aPoliticsSubjectClassification 题目分类
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("/save")
    public boolean save(@RequestBody APoliticsSubjectClassificationEntity aPoliticsSubjectClassification) {
        return aPoliticsSubjectClassificationService.save(aPoliticsSubjectClassification);
    }
    
    
    /**
     * 根据主键删除题目分类
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("/remove/{id}")
    public boolean remove(@PathVariable Serializable id) {
        return aPoliticsSubjectClassificationService.removeById(id);
    }
    
    
    /**
     * 根据主键更新题目分类
     * @param aPoliticsSubjectClassification 题目分类
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("/update")
    public boolean update(@RequestBody APoliticsSubjectClassificationEntity aPoliticsSubjectClassification) {
        return aPoliticsSubjectClassificationService.updateById(aPoliticsSubjectClassification);
    }
    
    
    /**
     * 查询所有题目分类
     * @return 所有数据
     */
    @GetMapping("/list")
    public List<APoliticsSubjectClassificationEntity> list() {
        return aPoliticsSubjectClassificationService.list();
    }
    
    
    /**
     * 根据题目分类主键获取详细信息。
     * @param id aPoliticsSubjectClassification主键
     * @return 题目分类详情
     */
    @GetMapping("/getInfo/{id}")
    public APoliticsSubjectClassificationEntity getInfo(@PathVariable Serializable id) {
        return aPoliticsSubjectClassificationService.getById(id);
    }
    
    
    /**
     * 分页查询题目分类
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("/page")
    public Page<APoliticsSubjectClassificationEntity> page(Page<APoliticsSubjectClassificationEntity> page) {
        return aPoliticsSubjectClassificationService.page(page);
    }
}